package com.situ.crm.controller.back;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.situ.crm.common.ServerResponse;
import com.situ.crm.entity.Product;
import com.situ.crm.service.IProductService;

@Controller
@RequestMapping("/product")
public class ProductController {

	@Autowired
	private IProductService productService; 
	//查询所有商品ID
	@RequestMapping("/selectProductId")
	@ResponseBody
	public ServerResponse selectProduct() {
		ServerResponse serverResponse = productService.selectProduct(); 
		
		return serverResponse;
	} 
	//跳转到商品展示界面
	@RequestMapping("/getPage")
	public String getPage() {
		
		return "/product/product";
	}
	//数据接口
	//分页查询
	@RequestMapping("/pageList")
	@ResponseBody
	public ServerResponse pageList(Integer page,Integer limit) {
		ServerResponse serverResponse = productService.pageList(page,limit);
		
		return serverResponse;
	}
	//跳转到添加界面
	@RequestMapping("/add")
	public String add() {
		
		return "/product/product_add";
	}
	//添加功能
	@RequestMapping("/insert")
	@ResponseBody
	public ServerResponse insert(Product product) {
		ServerResponse serverResponse = productService.insert(product);
		
		return serverResponse;
	}
}
